package com.totcy.atom.presenter;

import android.content.Context;

import com.totcy.atom.bean.AppVersion;
import com.totcy.atom.bean.ImagesBean;
import com.totcy.atom.model.CheckUpdateModel;
import com.totcy.atom.presenter.contract.ImageListContract;
import com.totcy.baselibrary.base.mvpbase.BasePresenterImpl;
import com.totcy.atom.presenter.contract.CheckUpdateContract;

import java.io.File;
import java.util.List;

public class CheckUpdatePresenter extends BasePresenterImpl<CheckUpdateContract.View, CheckUpdateContract.Model> implements CheckUpdateContract.Presenter, CheckUpdateContract.Model.DataCallback {

    public CheckUpdatePresenter(Context context) {
        super(context);
    }

    @Override
    public CheckUpdateContract.Model attachModel() {
        return new CheckUpdateModel(mContext);
    }

    @Override
    public void doCheckUpdate() {
        if (isModelAttached()) {
            getModel().doCheckUpdate(this);
        }
    }

    @Override
    public void downloadApk(String downloadUrl) {
        if (isModelAttached()) {
            getModel().downloadApk(downloadUrl,this);
        }
    }

    @Override
    public void onUpdateInfo(AppVersion appVersion) {
        if (isViewAttached()) {
            getView().onUpdateInfo(appVersion);
        }
    }

    @Override
    public void onDownloadFinish(File apkFileName) {
        if (isViewAttached()) {
            getView().onDownloadFinish(apkFileName);
        }
    }

    @Override
    public void onDownloadProgress(int progress) {
        if (isViewAttached()) {
            getView().onDownloadProgress(progress);
        }
    }
}
